/*
 * MusicLabs, Copyright (C) 2008-2009 Felippe Ragghianti
 * http://code.google.com/p/musiclabs
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 */


package br.com.music.scale;

/**
 * Musical modes are relative to the tonal center of a diatonic scale, and
 * encompasses every note of it as well; then it's enough to <b>rotate</b>
 * the diatonic scale -- given a tonic -- to obtain a Mode.
 */
public enum ModeType {

    /** Mode I, white note C. */
    IONIAN(0),

    /** Mode II, white note D. */
    DORIAN(-1),

    /** Mode III, white note E. */
    PHRYGIAN(-2),

    /** Mode IV, white note F. */
    LYDIAN(-3),

    /** Mode V, white note G. */
    MIXOLYDIAN(-4),

    /** Mode VI, white note A. */
    AEOLIAN(-5),

    /** Mode VII, white note B. */
    LOCRIAN(-6);

    private Integer rotationDistance;

    /**
     * Class constructor.
     *
     * @param rotationDistance
     */
    private ModeType(Integer rotationDistance) {
        this.rotationDistance = rotationDistance;
    }

    /**
     * Get rotation distance associated with this musical mode type.
     *
     * @return Returns the rotation distance as integer.
     */
    public Integer getRotationDistance() {
        return rotationDistance;
    }

    /**
     * Give mode type name as string.
     *
     * @return Returns the mode type as string.
     */
    @Override
    public String toString() {
        switch(this.rotationDistance) {
            case 0: return "Ionian";
            case -1: return "Dorian";
            case -2: return "Phrygian";
            case -3: return "Lydian";
            case -4: return "Mixolydian";
            case -5: return "Aeolian";
            case -6: return "Locrian";
            default: assert false; return null;
        }
    }
}
